Skip to content

fix(builtins): implement declare -f for function display and lookup#822

Merged
chaliy merged 1 commit intomainfrom
fix/issue-792-declare-f-function-check
Mar 26, 2026
Merged

fix(builtins): implement declare -f for function display and lookup#822
chaliy merged 1 commit intomainfrom
fix/issue-792-declare-f-function-check

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 26, 2026

Summary

  • Implement proper declare -f flag handling in the declare builtin
  • declare -f name now returns exit 1 when function doesn't exist (was always returning 0)
  • declare -f name prints function stub and returns 0 when function exists
  • declare -f with no args lists all defined functions
  • This completes subprocess isolation for script-by-path execution (feat: subprocess isolation for VFS script-by-path execution #792): the isolation itself (clearing functions in child scope) already worked, but declare -f helper always returned success regardless

Test plan

  • declare_f_nonexistent_function_returns_1 — verifies exit code 1 for missing functions
  • declare_f_existing_function_prints_definition — verifies exit code 0 and output for existing functions
  • declare_f_no_args_lists_all_functions — verifies listing all functions
  • exec_script_functions_not_inherited — verifies functions not visible in subprocess scripts
  • Full test suite passes (cargo test --all-features)
  • cargo fmt --check and cargo clippy clean

Closes #792

Closes #792 — `declare -f` now properly handles the -f flag:
- `declare -f name` returns exit 1 when function doesn't exist (was returning 0)
- `declare -f name` prints function definition and returns 0 when it exists
- `declare -f` with no args lists all defined functions

This fixes subprocess isolation for script-by-path execution: `declare -f`
was the last piece needed — the isolation itself (clearing functions in child)
already worked, but `declare -f helper` always returned success.
@chaliy chaliy merged commit d277c56 into main Mar 26, 2026
18 of 23 checks passed
@chaliy chaliy deleted the fix/issue-792-declare-f-function-check branch March 26, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: subprocess isolation for VFS script-by-path execution

1 participant